package com.example.controller;

import com.example.util.RedisService;
import com.example.vo.SysResult;
import com.example.vo.SysResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/redis")
public class RedisController {

    @Autowired
    private RedisService redisService;

    @RequestMapping(value = "/set/{key}/{value}")
    public SysResult set(@PathVariable String key, @PathVariable String value){
        redisService.set(key,value);
        return SysResult.ok();
    }

    @RequestMapping(value = "/get/{key}")
    public SysResultData get(@PathVariable String key) {
        String data = redisService.get(key);
        return SysResultData.ok(data);
    }

}
